using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameWork.TileMapManager;

// 1.控制玩家移动
public class PlayerControl : SingletonMonoBehaviour<PlayerControl>
{
    [Header("玩家基础信息")]
    [SerializeField] private float moveSpeed;
    
    [Header("玩家挂载组件")]
    private Rigidbody2D myrigidbody2D;

    protected override void Awake()
    {
        base.Awake();
        // 获取组件
        myrigidbody2D = GetComponent<Rigidbody2D>();
    }

    /// <summary>
    /// 移动函数
    /// </summary>
    public void Move()
    {
        // 输入方向 * 增衰系数 * 速度
        myrigidbody2D.velocity = new Vector2(PlayerInput.Instance.GetInputAxes.x * Player.Instance.GetPlayerMoveEffect() * moveSpeed, PlayerInput.Instance.GetInputAxes.y *Player.Instance.GetPlayerMoveEffect() * moveSpeed);
    }

    /// <summary>
    /// 静止函数
    /// </summary>
    public void Stop()
    {
        myrigidbody2D.velocity = Vector2.zero;
    }
}
